﻿@model IEnumerable<MoskieBlog.Data.Models.Post>

@{
    ViewBag.Title = "Blog";
    ViewBag.Message = "Posts";
}

<p>
    @Html.ActionLink("Create New", "Create")
</p>

<table class="table table-striped table-bordered table-condensed">
    <thead>
        <tr>
            <th class="span2">
                @Html.DisplayNameFor(model => model.Title)
            </th>
            <th class="span3">
                @Html.DisplayNameFor(model => model.Text)
            </th>
            <th class="span2">
                @Html.DisplayNameFor(model => model.PostedDate)
            </th>
            <th class="span2">
                @Html.DisplayNameFor(model => model.Poster.UserName)
            </th>
            <th class="span2"></th>
        </tr>
    </thead>
    <tbody>

@foreach (var item in Model) {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.Title)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Text)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.PostedDate)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Poster.UserName)
            </td>
            <td>
                <div class="btn-group">                    
                    @if (User.IsInRole("Manager") || User.IsInRole("Admin")) {
                    <a href="@Url.Action("Edit", new { id = item.PostId })" class="btn btn-primary btn-mini">
                        <i class='icon-pencil icon-white'></i>
                    </a>
                    }
                    <a href="@Url.Action("Details", new { id = item.PostId })" class="btn btn-primary btn-mini">
                        <i class='icon-search icon-white'></i>
                    </a>                    
                    @if (User.IsInRole("Manager") || User.IsInRole("Admin")) {
                    <a href="@Url.Action("Delete", new { id = item.PostId })" class="btn btn-danger btn-mini">
                        <i class='icon-remove icon-white'></i>
                    </a>
                    }
                </div>
            </td>
        </tr>
}
    </tbody>
</table>


@section featured {
<div class="page-header">
    <h1>
        @ViewBag.Title
        <small>@ViewBag.Message</small>
    </h1>
</div>
}
